package com.project.service;

import com.project.bean.UserBean;
import com.project.dao.IUserDao;
import com.project.dao.impl.UserDaoImpl;
import com.project.server.Request;
import com.project.server.Response;
import com.project.server.Servlet;
import com.project.server.WebServlet;

/**
 * 登陆业务组件
 */
@WebServlet("land")
public class LoginService  implements Servlet {
    private IUserDao userDao = new UserDaoImpl();
    /**
     * 业务方法
     * @param request 请求对象
     * @param response 响应对象
     */
    public void service(Request request, Response response){
        //得到表单数据
        String userName = request.getParameter("userName");
        String pwd = request.getParameter("pwd");

        //调用持久方法，得到结果
        UserBean user = userDao.login(userName,pwd);
        if(user == null){
            response.sendMessage("登陆失败");
        }
        else{
            response.sendMessage("登陆成功");
        }
    }
}
